import { axios } from '@/utils/request'
import querystring from 'querystring'
import config from '@/config/appConfig'

export function getCategoryTree (parameter) {
  return axios({
    url: config.url,
    method: 'get',
    params: {
      _gp: 'admin.category',
      _mt: 'categoryTree',
      ...parameter
    }
  })
}

export function deleteAdvertisement (parameter) {
  return axios({
    url: config.url,
    method: 'get',
    params: {
      _gp:'admin.advertisement',
      _mt:'deleteAdvertisement',
      ...parameter
    }
  })
}

export function getAdlist (parameter) {
  return axios({
    url: config.url,
    method: 'get',
    params: {
      _gp: 'admin.advertisement',
      _mt: 'queryAdvertisement',
      limit: 10,
      ...parameter
    }
  })
}
// 添加
export function buildSubmit (parameter) {
  return axios({
    url: config.url,
    method: 'post',
    data:querystring.stringify({
      _gp: 'admin.advertisement',
      _mt: 'addAdvertisement',
      ...parameter
    })
  })
}

// 编辑
export function editSubmit (parameter) {
  return axios({
    url: config.url,
    method: 'post',
    data:querystring.stringify({
      _gp: 'admin.advertisement',
      _mt: 'updateAdvertisement',
      ...parameter
    })
  })
}